package com.huichaoliu.data;

import java.io.File;

import javax.security.auth.SubjectDomainCombiner;

import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.example.huichaoliu.LoginActivity;
import com.rederxu.tools.FileUtils;
import com.rederxu.tools.StorageUtils;

public class Config {

	public static class REQUEST_URLS{
		private final static String BASE_URL = "http://211.149.205.68:8080/huichaoliu/";
		public final static String PAGE_GOODS_DETAIL = BASE_URL + "show.jsp?cid=";
		public final static String URL_SEND_REGISTER_SMS = BASE_URL + "service/action/sendregisterSMS.action";
		public final static String URL_SEND_FIND_PASSWORD_SMS = BASE_URL + "service/action/sendfindpassSMS.action";
		public final static String URL_COMMODITY_LIST = BASE_URL + "service/action/commoditylist.action";
		public final static String URL_USER_REGIST = BASE_URL + "service/action/userregister.action";
		public final static String URL_USER_LOGIN = BASE_URL + "service/action/userlogin.action";
		public final static String URL_USER_UPDATE_IMAGE = BASE_URL + "service/action/updateuserimage.action";
		public final static String URL_USER_PASSALTER = BASE_URL + "service/action/userpassalter.action";
		public final static String URL_USER_ADDRESS_LIST = BASE_URL + "service/action/useraddresslist.action";
		public final static String URL_USER_UPDATE_INFO = BASE_URL + "service/action/updateuserinfo.action";
		public final static String URL_USER_GET_MODEL_INFO = BASE_URL + "service/action/usermodelinfo.action";
		public final static String URL_USER_ADD_MODEL_INFO = BASE_URL + "service/action/addusermodel.action";
		public final static String URL_USER_ADD_ADDRESS_INFO = BASE_URL + "service/action/adduseraddress.action";
		public final static String URL_USER_MODIFY_ADDRESS_INFO = BASE_URL + "service/action/edituseraddress.action";
		public final static String URL_USER_DELETE_ADDRESS_INFO = BASE_URL + "service/action/deleteuseraddress.action";
		public final static String URL_USER_SET_ADDRESS_COMMON = BASE_URL + "service/action/useraddressiscommon.action";
		public final static String URL_COMMODITY_STYLE_LIST = BASE_URL + "service/action/commodityStylelist.action";
		public final static String URL_SHOPPING_ADD_BAG = BASE_URL + "service/action/addshoppingcar.action";
		public final static String URL_SHOPPING_COMMODITY_INFO = BASE_URL + "service/action/commodityinfo.action";
		public final static String URL_SHOPPING_BAG_LIST = BASE_URL + "service/action/shoppingcarlist.action";
		public final static String URL_SHOPPING_BAG_DELETE = BASE_URL + "service/action/deleteshoppingcar.action";
		public final static String URL_SHOPPING_LIKE = BASE_URL + "service/action/commoditypraise.action";
		public final static String URL_ORDER_ADD = BASE_URL + "service/action/addorder.action";
		public final static String URL_ORDER_LIST = BASE_URL + "service/action/orderlist.action";
	}
	
	public static final String FOLDER_ROOT = "/会潮流/";
	/***
	 * 得到应用文件夹
	 * 传入 folder = "images"
	 * return sdcard根目录 + "/会潮流/" + folder
	 * 并在目录不存在的时候新建目录
	 * */
	public static String getFolderPath(String folder){
		String path = StorageUtils.getSdCardPath() + FOLDER_ROOT + folder + "/";
		FileUtils.makeFolders(path);
		return path;
	}
	
	public static String getFolderImages(){
		return getFolderPath("images");
	}
	
	public static String getFolderCache(){
		return getFolderPath("cache");
	}
	
	public static boolean isOnline(Context mContext){
		UserInfo info = new UserInfo(mContext);
		if(info.getUid() == null){
			mContext.startActivity(new Intent(mContext,LoginActivity.class));
			return false;
		}else{
			return true;
		}
	}
	
	public static String getUserId(Context mContext){
		UserInfo info = new UserInfo(mContext);
		return info.getUid();
	}
}
